
import 'dart:async';

import 'package:isolate_pool_executor/isolate_pool_executor.dart';

class IsolatePoolUtil {

  static IsolatePoolUtil _instance = IsolatePoolUtil._();

  late IsolatePoolExecutor pool;

  IsolatePoolUtil._() {
    pool = IsolatePoolExecutor.newFixedIsolatePool(3);
  }

  static IsolatePoolUtil getInstance() {
    if (IsolatePoolUtil._instance == null) {
      _instance = IsolatePoolUtil._();
    }

    return _instance;
  }

  // TaskFuture<R> compute<Q, R>(FutureOr<R> Function(Q message) callback, Q message, {String? debugLabel, int what = 0, dynamic tag}) {
  //   return pool.compute(callback, message);
  // }

  void close() {
    if (pool.isShutdown) {
      pool.shutdown();
    }
  }
}